﻿using Beetle;
using System;

internal class Class_b : Attribute, IDisposable
{
    [Class_v]
    public static string _field_a = "KntezZn3/HTLy0OE4rsKQNgpdk";
    [Class_d]
    public static string _field_b = "baxxfKKgHV9XwOpsrn1uYA==";
    public static bool _field_c = false;
    public static bool _field_d = false;
    public byte[] _field_e;
    public int _field_f;
    public int _field_g;
    public int _field_h;
    private Class_a _field_i;
    private int _field_j;
    private ByteArraySegment _field_k;
    internal Class_ag _field_l;
    private bool _field_m;

    internal Class_b()
    {
        this._field_k = new ByteArraySegment();
    }

    public Class_b(int A_0)
    {
        this._field_k = new ByteArraySegment();
        this._field_f = A_0;
        this._field_e = new byte[A_0];
    }

    public Class_b(byte[] A_0)
    {
        this._field_k = new ByteArraySegment();
        this._field_e = A_0;
        this._field_f = A_0.Length;
        this._field_g = 0;
        this._field_h = A_0.Length;
    }

    public Class_b(int A_0, Class_a A_1)
    {
        this._field_k = new ByteArraySegment();
        this._field_f = A_0;
        this._field_e = new byte[A_0];
        this._field_i = A_1;
        this._field_i.SetBuffer(this._field_e, 0, A_0);
    }

    public void a()
    {
        this._field_m = false;
        this._field_g = 0;
        this._field_h = 0;
    }

    public void a(ByteArraySegment A_0)
    {
        this._field_e = A_0._field_a;
        this._field_g = A_0.Offset;
        this._field_h = A_0.Count;
    }

    public void a(params byte[] A_0)
    {
        for (int i = 0; i < A_0.Length; i++)
        {
            this._field_e[this._field_g] = A_0[i];
            this._field_g++;
            this._field_h++;
        }
    }

    public void a(Class_m A_0)
    {
        A_0._field_d = 0;
        if ((this._field_g + A_0._field_c) > this._field_f)
        {
            A_0._field_d = this._field_f - this._field_g;
        }
        else
        {
            A_0._field_d = A_0._field_c;
        }
        if (A_0._field_d > 0)
        {
            Buffer.BlockCopy(A_0._field_a, A_0._field_b, this._field_e, this._field_g, A_0._field_d);
            this._field_g += A_0._field_d;
            this._field_h += A_0._field_d;
            A_0._field_c -= A_0._field_d;
            A_0._field_b += A_0._field_d;
        }
    }

    public void a(byte A_0)
    {
        this._field_e[this._field_g] = A_0;
        this._field_g++;
        this._field_h++;
    }

    public bool a(int A_0)
    {
        return ((this._field_h - this._field_g) > A_0);
    }

    public void a(Array A_0, int A_1, int A_2)
    {
        Buffer.BlockCopy(A_0, A_1, this._field_e, 0, A_2);
        this._field_g = 0;
        this._field_h = A_2;
    }

    public Class_a b()
    {
        this._field_i.SetBuffer(0, this._field_h);
        return this._field_i;
    }

    public void b(int A_0)
    {
        this._field_g = 0;
    }

    public void c()
    {
        this.b(0);
    }

    public bool c(int A_0)
    {
        return ((this._field_f - this._field_h) >= A_0);
    }

    public void d()
    {
        if (this._field_i != null)
        {
            this._field_i.a((TcpChannel) null);
        }
    }

    public ByteArraySegment d(int A_0)
    {
        this._field_j = A_0;
        if ((this._field_g + A_0) > this._field_h)
        {
            this._field_j = this._field_h - this._field_g;
        }
        this._field_k.SetInfo(this._field_e, this._field_g, this._field_j);
        this._field_g += this._field_j;
        return this._field_k;
    }

    public void Dispose()
    {
        lock (this)
        {
            if (!this._field_m)
            {
                this._field_m = true;
                if (this._field_l != null)
                {
                    this._field_l.a(this);
                }
            }
        }
    }

    public ByteArraySegment i()
    {
        this._field_k.SetInfo(this._field_e, 0, this._field_h);
        return this._field_k;
    }
}

